Skip to content

fix: remove unnecessary platform check in AppItem tooltip#1566

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-344907
Apr 22, 2026
Merged

fix: remove unnecessary platform check in AppItem tooltip#1566
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
wjyrich:fix-bug-344907

Conversation

@wjyrich
Copy link
Copy Markdown
Contributor

@wjyrich wjyrich commented Apr 22, 2026

  1. Removed the platform-specific check Qt.platform.pluginName === "xcb" from the onEntered function
  2. The condition now only checks if there are no windows, regardless of the platform
  3. This fix ensures consistent tooltip behavior across all display backends (X11/Wayland)

Influence:

  1. Verify tooltip shows correctly when no windows are open on X11
  2. Verify tooltip shows correctly when no windows are open on Wayland
  3. Test tooltip behavior when windows are present on both platforms
  4. Ensure no regression in existing tooltip functionality

fix: 移除AppItem工具提示中不必要的平台检查

  1. onEntered函数中移除了平台特定的检查Qt.platform.pluginName === "xcb"
  2. 现在条件仅检查是否有窗口存在,与平台无关
  3. 此修复确保在所有显示后端(X11/Wayland)上工具提示行为一致

Influence:

  1. 验证在X11上无窗口时工具提示正常显示
  2. 验证在Wayland上无窗口时工具提示正常显示
  3. 测试两种平台上存在窗口时的工具提示行为
  4. 确保现有工具提示功能无回归问题

PMS: BUG-344907

Summary by Sourcery

Bug Fixes:

  • Fix AppItem tooltip visibility logic so it triggers based only on whether any windows exist, not on the Qt X11 platform plugin.

1. Removed the platform-specific check `Qt.platform.pluginName ===
"xcb"` from the `onEntered` function
2. The condition now only checks if there are no windows, regardless of
the platform
3. This fix ensures consistent tooltip behavior across all display
backends (X11/Wayland)

Influence:
1. Verify tooltip shows correctly when no windows are open on X11
2. Verify tooltip shows correctly when no windows are open on Wayland
3. Test tooltip behavior when windows are present on both platforms
4. Ensure no regression in existing tooltip functionality

fix: 移除AppItem工具提示中不必要的平台检查

1. 从`onEntered`函数中移除了平台特定的检查`Qt.platform.pluginName ===
"xcb"`
2. 现在条件仅检查是否有窗口存在,与平台无关
3. 此修复确保在所有显示后端(X11/Wayland)上工具提示行为一致

Influence:
1. 验证在X11上无窗口时工具提示正常显示
2. 验证在Wayland上无窗口时工具提示正常显示
3. 测试两种平台上存在窗口时的工具提示行为
4. 确保现有工具提示功能无回归问题

PMS: BUG-344907
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 22, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes a platform-specific Qt plugin check from the AppItem tooltip enter/exit handlers so that tooltip visibility is controlled solely by whether any windows exist, ensuring consistent behavior across X11 and Wayland.

Flow diagram for updated AppItem tooltip onEntered and onExited logic

flowchart TD
  A_Hover_enter[User hovers over AppItem]
  B_Check_windows_on_enter{windows.length === 0}
  C_Start_tooltip_timer[Start toolTipShowTimer]
  D_Exit_enter_handler[Return from onEntered]
  E_Show_previews_or_other_behavior[Handle case when windows exist]

  A_Hover_enter --> B_Check_windows_on_enter
  B_Check_windows_on_enter -->|true| C_Start_tooltip_timer
  C_Start_tooltip_timer --> D_Exit_enter_handler
  B_Check_windows_on_enter -->|false| E_Show_previews_or_other_behavior

  F_Hover_leave[User leaves AppItem]
  G_Stop_preview_timer[Stop previewTimer]
  H_Check_windows_on_exit{windows.length === 0}
  I_Close_tooltip[Close toolTip]
  J_Exit_exit_handler[Return from onExited]
  K_Keep_tooltip_or_previews[Keep existing tooltip or preview behavior]

  F_Hover_leave --> G_Stop_preview_timer
  G_Stop_preview_timer --> H_Check_windows_on_exit
  H_Check_windows_on_exit -->|true| I_Close_tooltip
  I_Close_tooltip --> J_Exit_exit_handler
  H_Check_windows_on_exit -->|false| K_Keep_tooltip_or_previews

  classDef default fill:#f5f5f5,stroke:#333,stroke-width:1px
Loading

File-Level Changes

Change Details Files
Simplify tooltip show/close conditions to depend only on window presence, not platform.
  • Updated onEntered handler to start the tooltip timer whenever there are no windows, regardless of Qt platform plugin.
  • Updated corresponding tooltip close logic to mirror the new, platform-agnostic condition for no-window state.
panels/dock/taskmanager/package/AppItem.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

这段代码的修改移除了对 Qt.platform.pluginName === "xcb" 的判断条件。以下是对该修改的详细审查意见:

1. 语法逻辑审查

现状
修改前,代码逻辑为:if (Qt.platform.pluginName === "xcb" && windows.length === 0)
修改后,代码逻辑为:if (windows.length === 0)

分析

  • 语法正确性:修改后的语法完全正确,符合 QML/JavaScript 语法规范。
  • 逻辑变化:原代码限制了逻辑仅在 X11 (xcb) 平台上生效。移除该条件后,逻辑将在所有平台(如 Wayland)上生效。

2. 代码质量审查

改进点

  • 通用性增强:移除平台特定的硬编码判断,使得代码逻辑更加通用,减少了平台耦合度。
  • 代码简化:移除了不必要的条件判断,使代码更简洁,可读性更高。

潜在风险

  • 平台兼容性:需要确认在 Wayland 或其他非 X11 平台上,toolTip 的行为是否与 X11 一致。如果不同平台对工具提示的处理机制不同,此修改可能导致非预期行为(例如 Wayland 下可能不需要或不应显示工具提示)。

3. 代码性能审查

  • 性能提升:移除 Qt.platform.pluginName 的字符串比较,减少了函数调用和字符串比较的开销,尽管影响微小,但在高频触发的 onEnteredonExited 事件中是有益的。

4. 代码安全审查

  • 逻辑安全性:移除平台判断后,逻辑更加统一,减少了因平台差异导致的分支逻辑错误。
  • 边界情况:需要确保 windows 数组在所有平台上都能正确初始化和访问,避免因平台差异导致的空指针或未定义行为。

综合改进建议

  1. 测试覆盖

    • 在 Wayland 和 X11 环境下分别测试工具提示的显示和隐藏行为,确保一致性。
    • 测试极端情况(如 windows 为空或未初始化时)的行为。
  2. 注释补充

    • 如果移除平台判断是有意为之,建议添加注释说明原因,例如:
      // 统一所有平台的工具提示行为,不再区分 X11/Wayland
      if (windows.length === 0) {
          toolTipShowTimer.start()
          return
      }
  3. 代码健壮性

    • 如果 windows 可能为 nullundefined,建议增加防御性检查:
      if (!windows || windows.length === 0) {
          toolTipShowTimer.start()
          return
      }

总结

该修改在语法和逻辑上是正确的,提升了代码的通用性和性能,但需要确保在所有目标平台上的行为一致性。建议补充测试和注释以增强代码的健壮性和可维护性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wjyrich
Copy link
Copy Markdown
Contributor Author

wjyrich commented Apr 22, 2026

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented Apr 22, 2026

This pr force merged! (status: behind)

@deepin-bot deepin-bot Bot merged commit 2ccf53c into linuxdeepin:master Apr 22, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants